#ifndef __AM_LOG_H
#define __AM_LOG_H
//#include "stb_sprintf.h"
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include "timestamp.h"
#ifdef __cplusplus
 extern "C" {
#endif

typedef enum{
    AM_LOG_LEVEL_VERBOSE,
    AM_LOG_LEVEL_DEBUG,
    AM_LOG_LEVEL_INFO,
    AM_LOG_LEVEL_WARNING,
    AM_LOG_LEVEL_FATAL,
    AM_LOG_LEVEL_SILENT,
    AM_LOG_LEVEL_MAX
}amLogLevelTypeDef;

extern uint8_t g_logout_en;

#define AM_LOG_DEFAULT_PRINT_LEVEL  AM_LOG_LEVEL_INFO

/*******************/
extern volatile uint32_t   g_u32ToVcuDmaTxFlg;
extern volatile uint32_t   g_u32ToApDmaTxFlg;
extern volatile uint32_t   g_u32ToDbgDmaTxFlg;

void log_print(uint32_t u32Level, uint32_t u32WithTimestamp, const char* ps8Tag, const char* ps8Format, ...);

#define LOG(level, tag, format, ...) \
    log_print(level, 2, tag, format, ##__VA_ARGS__)

#define LOG_TS(level, tag, format, ...) \
    log_print(level, 1, tag, format, ##__VA_ARGS__)

#define LOG_Clear(format, ...) \
    log_print(AM_LOG_LEVEL_MAX, 0, NULL, format, ##__VA_ARGS__)


int32_t LOG_STR(const uint8_t *data_p, uint32_t len);
int32_t LOG_STRH(uint32_t u32Level, uint32_t u32WithTimestamp, const char* ps8Tag, const uint8_t *data_p, int32_t len);
int32_t LOG_HEX(const uint8_t *data_p, uint32_t len, uint32_t withTail);

void set_log_level(uint8_t level);
uint8_t get_log_level(void);

uint8_t get_log_switch(void);

#ifdef __cplusplus
}
#endif

#endif
